#ifndef __TIMESUMFILTER_H__
#define __TIMESUMFILTER_H__

#include "plat/nonecopyable.h"

/// @brief 给定时间范围的平均滤波 [简单模型]
/// @name
class TimeSumFilter : public NoneCopyable
{
public:
    explicit TimeSumFilter();
    explicit TimeSumFilter(int maxMs);
    virtual ~TimeSumFilter();

public:
    void SetMaxMs(int maxMs);

    bool Add(int ms, float v);
    float GetValue();
    void Reset();

private:
    int m_maxMs = 0;

    int m_ms = 0;
    int m_count = 0;
    float m_sum = 0;
    
    float m_val = 0;
};

#endif // __TIMESUMFILTER_H__
